<?php include _include(APP_PATH.'view/htm/header.inc.htm');
$stamps = array("精华","热帖","美图","优秀","置顶","推荐","原创","版主推荐","爆料","编辑采用");
$stamps_count = count($stamps);
?>

<div class="card">
	<div class="card-header"><?php echo lang('stamp_thread');?></div>
	<div class="card-body ajax-body">
		<form action="<?php echo url("mod-stamp");?>" method="post" id="mod_stamp_form">
			<div class="form-group row"><label class="col-3 form-control-label text-right"><?php echo lang('total');?>：</label><div class="col-9"><span class="total font-weight-bold text-danger"></span> <?php echo lang('piece');?></div>
			</div><div class="form-group row"><label class="col-3 form-control-label text-right">图章类别：</label>
				<div class="col-9">
					<label class="custom-input custom-radio"><input type="radio" name="stamp" value="0" />删除图章</label>　
					<?php for($i=0;$i<$stamps_count;$i++){ ?><label class="custom-input custom-radio"><input type="radio" name="stamp" value="<?php echo ($i+1);?>" /><?php echo $stamps[$i];?></label>　 <?php }?>
				</div></div>
			<div class="form-group row"><label class="col-3 form-control-label text-right"></label>
				<div class="col-sm-9"><button type="submit" class="btn btn-primary mr-2" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button><button type="button" class="btn btn-secondary"><?php echo lang('close');?></button></div></div>
		</form></div></div>

<?php include _include(APP_PATH.'view/htm/footer.inc.htm'); ?>

<script ajax-eval="true">

    // 接受传参
    var args = args || {jmodal: null, callback: null, arg: null};
    var jmodal = args.jmodal;
    var callback = args.callback;
    var arg = args.arg;
    var jthreadlist = $(arg);  // .threadlist
    var tidarr = jthreadlist.find('input[name="modtid"]').checked();
    var jform = $('#mod_stamp_form');
    var jsubmit = jform.find('button[type="submit"]');
    var jcancel = jform.find('button[type="button"]');
    var jstamp = jform.find('input[name="stamp"]');
    var jtotal = jform.find('span.total');
    jtotal.text(tidarr.length);
    jform.on('submit', function() {
        jform.reset();
        jsubmit.button('loading');
        var postdata = jform.serializeObject();
        postdata.tidarr = tidarr;
        postdata.stamp = jstamp.checked();
        $.xpost(jform.attr('action'), postdata, function(code, message) {
            if(code == 0) {
                jsubmit.button(message);
                setTimeout(function() {
                    if(jmodal) jmodal.modal('dispose');
                    if(callback) callback(message);
                    window.location.reload();
                }, 1000);
            } else {
                alert(message);
                jsubmit.button('reset');
            }
        });
        return false;
    });
    jcancel.on('click', function() {
        if(jmodal) jmodal.modal('dispose');
    });
</script>